package com.hotel.app.controller;

import cn.hutool.core.convert.NumberWithFormat;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hotel.app.service.UserFeign;
import com.hotel.common.config.SystemConfig;
import com.hotel.common.param.RestPwd;
import com.hotel.common.param.UserAdd;
import com.hotel.common.param.UserLogin;
import com.hotel.common.util.JwtUtil;
import com.hotel.common.vo.R;
import com.hotel.user.entity.UserLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/api/user")
public class UserController {

    @Autowired
    private UserFeign userFeign;
    /**
     * 注册接口
     * @param userAdd
     * @return
     */
    @RequestMapping("/register")
    public R register(@RequestBody UserAdd userAdd){

        return    userFeign.register(userAdd);
    }


    // 账号 + 密码 登录
    @RequestMapping("/loginpass")
    public R loginpass(@RequestBody UserLogin userLogin){

        return userFeign.loginpass(userLogin);

    }

    // 手机号  验证码
    @RequestMapping("/logincode")
    public  R logincode(@RequestBody UserLogin userLogin){
        return userFeign.logincode(userLogin);
    }

    //重置代码
    @RequestMapping("/reset")
    public R reset(@RequestBody RestPwd restPwd){

        return userFeign.reset(restPwd);

    }

    // 退出登录
    @RequestMapping(value = "/logout",method = RequestMethod.GET)
    public R logout(HttpServletRequest request){

        String token = request.getHeader(SystemConfig.HEADER_TOKEN);
        return userFeign.logout();

    }

    @RequestMapping(value = "/info",method = RequestMethod.GET)
    public R findUserInfoById() {
        return userFeign.findUserInfoById();
    }




}